package com.scau.service.impl;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import com.scau.dao.IProductDao;
import com.scau.service.IProductService;
import com.scau.util.DateTransform;
import com.scau.vo.Product;

/**
 * @author Jinglun
 * @create 2017年4月18日
 */
public class ProductServiceImpl implements IProductService {

	IProductDao productDao;
	
	@Override
	public boolean saveProduct(Product product) {
		// 当前时间由Date->Timestamp
		Date date = new Date();
		DateTransform dt = new DateTransform();
		Timestamp create = dt.dToTimestamp(date);
		product.setGmtCreate(create);
		return productDao.saveProduct(product);
	}

	@Override
	public boolean deleteProduct(int id) {
		return productDao.deleteProduct(id);
	}

	@Override
	public List<Product> listProduct() {
		return productDao.listProduct();
	}

	@Override
	public boolean updateProduct(Product product) {
		// 当前时间由Date->Timestamp
		Date date = new Date();
		DateTransform dt = new DateTransform();
		Timestamp modified = dt.dToTimestamp(date);
		product.setGmtModified(modified);
		return productDao.updateProduct(product);
	}

	// get,set方法
	public IProductDao getProductDao() {
		return productDao;
	}

	public void setProductDao(IProductDao productDao) {
		this.productDao = productDao;
	}

}
